package utils

import (
	"fmt"
	"github.com/oklog/ulid"
	"math/rand"
	"time"
)

func GenerateCode() string {
	t := time.Now().UTC()
	entropy := rand.New(rand.NewSource(t.UnixNano()))
	id := ulid.MustNew(ulid.Timestamp(t), entropy)
	return id.String()
}

func GenerateSpecialCode(prefixStr string) string {
	timeStr := time.Now().Format("2006")
	return fmt.Sprintf("%s%s", prefixStr, timeStr)
}
